Skip to content

fix: handle in/notin operators in token search filters#1656

Merged
rohilsurana merged 4 commits into
mainfrom
token-page-filters
Jun 3, 2026
Merged

fix: handle in/notin operators in token search filters#1656
rohilsurana merged 4 commits into
mainfrom
token-page-filters

Conversation

@rohilsurana
Copy link
Copy Markdown
Member

Summary

  • Add explicit in/notin operator handling in OrgTokensRepository.addFilter
  • The in operator requires splitting comma-separated string values into a slice for goqu's In() method
  • Without this, goqu.Op{"in": "system.buy"} generates invalid SQL — it passes a raw string instead of a list to IN ()
  • Same pattern as OrgBillingRepository.addRQLFiltersInQuery which already handles this correctly

Root cause

The DataTable multiselect filter sends operator: "in" with stringValue: "system.buy" (comma-separated for multiple values). The addFilter default case passes this directly to goqu as goqu.Op{"in": filter.Value}, but goqu's in needs a slice, not a string. The fix splits the value by commas before passing to In()/NotIn().

Test plan

  • Open tokens page → Filter → Event → select "Recharge" → verify filtered results appear
  • Select multiple event types → verify comma-separated values filter correctly
  • Use "is not" operator → verify notin works

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Jun 3, 2026 4:55pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Review Change Stack

Warning

Review limit reached

@rohilsurana, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 20 minutes and 37 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 94b64931-3c28-4ab0-9619-b4d4573817af

📥 Commits

Reviewing files that changed from the base of the PR and between 63412b4 and dbc2c9c.

📒 Files selected for processing (1)
  • internal/store/postgres/org_tokens_repository.go
📝 Walkthrough

Walkthrough

The PR extends OrgTokensRepository.addFilter to support "in" and "notin" operators by parsing comma-separated values (using strings) and generating TEXT-cast SQL IN/NOT IN predicates from the resulting list.

Changes

Filter Operator Extension

Layer / File(s) Summary
In/NotIn filter operators implementation
internal/store/postgres/org_tokens_repository.go
OrgTokensRepository.addFilter now handles "in" and "notin" by splitting comma-separated values, trimming and discarding empties, casting the target to TEXT, and emitting IN/NOT IN predicates; strings imported to support parsing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • rsbh
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e693f884-d065-4e95-abdd-bb22f50d3118

📥 Commits

Reviewing files that changed from the base of the PR and between e399d9c and 8aadd5b.

📒 Files selected for processing (1)
  • internal/store/postgres/org_tokens_repository.go

Comment thread internal/store/postgres/org_tokens_repository.go Outdated
@coveralls
Copy link
Copy Markdown

coveralls commented May 27, 2026

Coverage Report for CI Build 26899856118

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage decreased (-0.02%) to 43.138%

Details

  • Coverage decreased (-0.02%) from the base build.
  • Patch coverage: 13 uncovered changes across 1 file (0 of 13 lines covered, 0.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
internal/store/postgres/org_tokens_repository.go 13 0 0.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 38013
Covered Lines: 16398
Line Coverage: 43.14%
Coverage Strength: 12.08 hits per line

💛 - Coveralls

Comment thread internal/store/postgres/org_tokens_repository.go Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
internal/store/postgres/org_tokens_repository.go (1)

171-176: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Empty value list yields NOT IN () / IN () and silently matches every / no row.

When the input is "" or just ",", values ends up empty and the predicate degrades into an always-true (notin) or always-false (in) clause. Consider bailing out with a postgres.ErrBadInput-wrapped error so the handler can map it to a 400 instead of returning unexpected rows.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aede523b-db47-4675-94a0-ef0eb7b84c82

📥 Commits

Reviewing files that changed from the base of the PR and between 3aba0ed and a26e497.

📒 Files selected for processing (1)
  • internal/store/postgres/org_tokens_repository.go

Comment thread internal/store/postgres/org_tokens_repository.go Outdated
@rohilsurana rohilsurana force-pushed the token-page-filters branch from 63412b4 to dbc2c9c Compare June 3, 2026 16:54
@rohilsurana rohilsurana enabled auto-merge (squash) June 3, 2026 16:58
@rohilsurana rohilsurana merged commit 2e93a90 into main Jun 3, 2026
8 checks passed
@rohilsurana rohilsurana deleted the token-page-filters branch June 3, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants